package ansi.servlet.reserva;

import java.io.IOException;
import java.util.Collection;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ansi.modelo.AreaComun;
import ansi.modelo.Reserva;
import ansi.negocio.GestionAreaComun;
import ansi.negocio.GestionReserva;

/**
 * Servlet implementation class AreaComunRegistroServlet
 */
@WebServlet("/ReservaBuscarServlet")
public class ReservaBuscarServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ReservaBuscarServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		buscar(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		buscar(request, response);
	}
	
	protected void buscar(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			Collection<Reserva> list	= null;
			GestionReserva gestionReserva	= new GestionReserva();
			list	= gestionReserva.listar();
			request.setAttribute("reservaList", list);
			RequestDispatcher rd = request.getRequestDispatcher("reserva_editar.jsp");
			rd.forward(request, response);
		} catch(Exception ex) {
			ex.printStackTrace();
		}
	}

}
